const http = require('http')

const server = http.createServer((request,response) => { 
    response.setHeader('content-type',"text/html;charset=utf-8")
    const {method} = request
    const {pathname} = new URL(request.url,'http://127.0.0.1')
    if (method === 'GET' && pathname === '/login') {
        response.end('登录页面')
    }else if(method === 'POST' && pathname === '/register') {
        response.end('注册页面')
    }else {
        response.end('404 Not Found')
    }
 }
)

server.listen(3000,() => {
    console.log('服务启动成功！')
})